﻿@model IEnumerable<EC_ASS.Models.Feedback>
<table class="table table-bordered">
    <thead>
        <th>Khách hàng</th>
        <th>Email</th>
        <th>Nội dung</th>
        <th>Ngày feedback</th>
        <th>Thao tác</th>
    </thead>
    <tbody>
        @foreach (var item in Model)
        {
            <tr class="success">
                <td>@item.Customer</td>
                <td>@item.Email</td>
                @if (item.Content.Length > 20)
                {
                    <td>
                        @(item.Content.Substring(0, 17) + " ...")
                    </td>
                    }
                else
                {
                    <td>
                        @item.Content
                    </td>
                    }
                <td>@item.Time</td>
                <td>
                    @Html.ActionLink("Sữa", "EditFeedback", "Admin", null, new { @class = "btn edit-feedback", @feedbackID = item.ID })
                    @Html.ActionLink("Xóa", "DeleteFeedback", "Admin", null, new { @class = "btn delete-feedback", @feedbackID = item.ID })
                </td>
            </tr>
        }
    </tbody>
</table>
<script type="text/javascript">
    $(function () {
        $('.edit-feedback').click(function () {
            var itemID = $(this).attr('feedbackID');
            var editUrl = this.href + '/' + itemID;
            $('#editModalContent').load(editUrl, function () {
                $('#editModal').modal({
                    backdrop: 'static',
                    keyboard: true
                }, 'show');
                $('#editLoading').hide();
            });
            return false;
        });

        $('.delete-feedback').click(function () {
            var fbID = $(this).attr('feedbackID');
            var deleteUrl = this.href;
            $.ajax({
                type: "GET",
                url: deleteUrl,
                data: { id: fbID },
                success: function (result) {
                }
            });
            setTimeout(function () {
                $('#listFeedbackTable').load('@Url.Action("_ListFeedbackPage", "Admin")').hide().fadeIn('slow');
            }, 2000);
            return false;
        });
    });
</script>
